package com.aaron.jackson;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Date;

/**
 * @author liurong
 * @date 2021/11/26 18:38
 * @version:
 */
public class DateJsonFormatTest {

    @JSONField(format = "yyyyMMdd")
    private Date date;

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public static void main(String[] args) throws Exception{
        DateJsonFormatTest test = new DateJsonFormatTest();
        test.setDate(new Date());
//        ObjectMapper objectMapper = new ObjectMapper();
//        System.out.println(objectMapper.writeValueAsString(test));
        System.out.println(JSON.toJSONString(test));
    }
}

